\section{Zone Equipment Simulation}\label{zone-equipment-simulation}

When the EnergyPlus HVAC simulation manager needs to simulate the zone equipment side of the air loop it calls \emph{ManageZoneEquipment}, the zone equipment simulation manager subroutine. Like the other managers, \emph{ManageZoneEquipment} has a very simple structure:

\begin{lstlisting}
IF (GetInputFlag) THEN
  CALL GetZoneEquipment
  GetInputFlag = .FALSE.
END IF

CALL InitZoneEquipment(FirstHVACIteration)

IF (ZoneSizingCalc) THEN
  CALL SizeZoneEquipment
ELSE
  CALL SimZoneEquipment(FirstHVACIteration, SimAir)
END IF

CALL RecordZoneEquipment(SimAir)

CALL ReportZoneEquipment

SimZone = .False.

RETURN
\end{lstlisting}

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
  If the user input data has not been input, get the data and store it in the zone equipment data structures
\item
  Perform zone equipment initialization calculations.
\item
  If calculation of the design zone air flow rates and loads needs to be done, do it. The results of this calculation are stored in the zone sizing and air terminal sizing data structures and used by the component automatic sizing algorithms and the central system sizing calculations.
\item
  Otherwise simulate all of the zone equipment.
\item
  Transfer the zone equipment outlet node data to the inlet nodes of the primary air systems and check for convergence (done in RecordZoneEquipment by calling UpdateHVACInterface).
\end{enumerate}

\subsection{Input data}\label{input-data-000}

The input specifying a set of zone equipment consists of:

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\def\labelenumii{\alph{enumii}.}
\def\labelenumiii{\roman{enumiii}.}
  \item
    the ZoneHVAC:EquipmentConnections object data;
    \begin{enumerate}
      \item the zone connection to the air loop – air inlet nodes, exhaust nodes, return nodes, and zone node;
      \item the components serving each zone – air terminal units, fan coils etc.;
    \end{enumerate}
  \item
    zone supply air path data;
    \begin{enumerate}
      \item zone splitters and supply plenums;
    \end{enumerate}
  \item
    zone return air path data;
    \begin{enumerate}
      \item zone mixers and return plenums;
    \end{enumerate}
\end{enumerate}

\subsection{Initialization Calculations}\label{initialization-calculations-000}

\subsubsection{One Time Calculations}\label{one-time-calculations-000}

There are no one time calculations for zone equipment

\subsubsection{Begin Environment Initializations}\label{begin-environment-initializations-000}

For each controlled zone initialize the zone inlet, exhaust and zone nodes to standard conditions. Namely:

\begin{equation}
{T_{node}} = {20^{\rm{o}}}C
\end{equation}

\begin{equation}
{W_{node}} = {W_{oa}}
\end{equation}

\begin{equation}
{h_{node}} = {\mathop{\rm PsyHFnTdbW}\nolimits} {\rm{(}}20.0,{W_{oa}}{\rm{)}}
\end{equation}

\begin{equation}
{\dot m_{node}} = 0
\end{equation}

\begin{equation}
Q{u_{node}} = 1.0
\end{equation}

\begin{equation}
{p_{node}} = {p_{oa}}
\end{equation}

where \emph{W\(_{oa}\)} is the humidity of the outside air; \({\rm{PsyHFnTdbW}}\) is the EnergyPlus psychrometric function for enthalpy \emph{h}, given temperature and humidity ratio; \emph{p\(_{oa}\)} is the pressure of the outside air; and \emph{Qu} is quality.

\subsubsection{System Time Step Initializations}\label{system-time-step-initializations-000}

For each controlled zone, set the exhaust nodes conditions equal to the zone node conditions; except set the exhaust nodes mass flow rate and min and max available mass flow rates to zero.

\subsection{Simulation}\label{simulation-003}

The subroutine \emph{SimZoneEquipment} does the actual simulation of all the zone equipment. Note that this includes components that are part of the demand side of an air loop as well as components that are independent of any air loop.

For zone equipment components that are part of the demand side of an air loop the simulation sequence is effectively performed in the direction of the air flow. First the supply air plenums and zone splitters are simulated in their input order. Then the air terminal units are simulated followed by the zone return plenums and zone mixer. Each air terminal unit sets its inlet node to the air mass flow rate required to satisfy its zone load. These mass flow rates are then passed back upstream to the air loop demand-side inlet nodes at the end of each zone equipment simulation sequence. These demand-side inlet mass flow rates are then used as mass flow rate setpoints in the air loop supply-side simulation.

If multiple air-conditioning components are attached to a zone, the components are simulated in the order specified by the user assigned priority given in the ZoneHVAC:EquipmentList object, using one of four load distribution schemes. See Zone Equipment Load Distribution described in \ref{zone-equipment-load-distribution}

For each full air loop there should be 1 supply air path for each primary air system outlet (i.e.~1 for single duct systems,~ 2 for dual duct systems). For each full air loop there may be one return air path. The supply air paths consist of any combination of zone splitters and zone supply air plenums as long as it forms a tree structure with the supply air path inlet node the root and the air terminal unit inlet nodes as the leaves. The return air paths consist of any combination of zone mixers and zone return air plenums as long as it forms a tree structure with the demand-side outlet node the root and the zone return air nodes as the leaves.

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\def\labelenumii{\alph{enumii}.}
\def\labelenumiii{\roman{enumiii}.}
  \item
    Loop over all the supply air paths.
    \begin{enumerate}
      \item
        Loop over each component (supply plenum or zone splitter) on the supply air path and simulate each component. The components are simulated in input order.
    \end{enumerate}
  \item
    Loop over all the controlled zones.
    \begin{enumerate}
      \item
        Set the required system output.
      \item
        Loop over the components serving the zone in the user prioritized order.
        \begin{enumerate}
          \item
            Simulate each component.
          \item
            Increment the required system output.
        \end{enumerate}
    \end{enumerate}
  \item
    Loop over all the supply air paths
    \begin{enumerate}
      \item
        Loop over the components on each supply air path in reverse input order. This reverse order simulation passes the air terminal units inlet mass flows back upstream to the return air path inlet node.
      \item
        Check to see if the supply air path inlet node mass flow rate has changed. If it has set the \emph{SimAir} flag to \emph{true}. This signals the HVAC manager that the supply-side of the air loop needs to be resimulated.
    \end{enumerate}
  \item
    Calculate the zone air flow mass balance -- the zone inlet and exhaust mass flow rates are summed and the zone node and return air node mass flow rates are determined by a mass balance for each zone.
  \item
    Calculate the conditions at each zone return air node. Here energy not included in the zone energy balance such as light-heat-to-return-air is added to the return nodes of the controlled zones.
  \item
    Loop over all of the return air paths.
    \begin{enumerate}
      \item
        Loop over each component (return plenum or zone mixer) on the return air path and simulate each component.
    \end{enumerate}
\end{enumerate}

This completes a single simulation sequence of all the zone equipment.

\subsection{Zone Equipment Load Distribution}\label{zone-equipment-load-distribution}

The function \emph{DistributeSystemOutputRequired} allocates the current zone load among the available pieces of zone equipment for the current load type (cooling, heating, or no-load). Because some air loop components such as AirLoopHVAC:UnitarySystem may be controlled based on a control zone load, the sequenced loads must be known prior to the final iteration of the HVAC simulation so that the air loop equipment will adjust its output accordingly. When the zone equipment list is initially read, the maximum number of equipment across all zones is used to set the number of air loop iterations required after the initial iteration, \emph{MinAirLoopIterationsAfterFirst}. The control sequence is shown below.
\begin{enumerate}
\item
  Initial iteration (\emph{FirstHVACIteration} is true)
  \begin{enumerate}
  \item
    Set all sequenced loads to the full zone design load for the current load type (cooling or heating).
  \item
    Simulate air loops and zone equipment.
  \item
    Do not adjust any of the sequenced loads - all equipment is called with the design load.
  \item
    Store the sensible output (capacity) for each piece of equipment.
  \end{enumerate}
\item
  Second iteration (\emph{FirstHVACIteration} is false)
  \begin{enumerate}
  \item
    Set all sequenced loads according to the specified load distribution scheme:
    \begin{itemize}
    \item
      SequentialLoad - Initially all sequenced loads are set to the full load required.
    \item
      UniformLoad - The sequenced loads for all active equipment are set to the full load divided by the number of active pieces of equipment. All inactive sequenced loads are set to zero.
    \item
      UniformPLR - Using the current equipment capacities (stored during the initial iteration), distribute the load among the available pieces of equipment, such that each one is operating at the same part load ratio (PLR).
    \item
      SequentialUniformPLR - Using the current equipment capacities (stored during the initial iteration), determine how many of the available pieces of equipment are required to meet the current full load.  Then distribute the load among those pieces of equipment, such that each one is operating at the same part load ratio (PLR).
    \end{itemize}
  \item
    Simulate air loops.
  \item
    Simulate zone equipment.
    \begin{itemize}
    \item
      If the load distribution type is SequentialLoad, update each successive sequenced load to be the current remaining load.
    \item
      Otherwise, leave the sequenced loads as-is from the initial distribution.
    \end{itemize}
  \end{enumerate}
\item
  Third iteration and beyond (\emph{FirstHVACIteration} is false)
  \begin{enumerate}
  \item
    Simulate air loops.
  \item
    Simulate zone equipment.
    \begin{itemize}
    \item
      If the load distribution type is SequentialLoad, update each successive sequenced load to be the current remaining load.
    \item
      Otherwise, leave the sequenced loads as-is from the initial distribution.
    \end{itemize}
  \end{enumerate}
\end{enumerate}
